{echo:JS::import("form")}
{echo:JS::import('dialog?skin=simple');}
{echo:JS::import('dialogtools');}
<link type="text/css" rel="stylesheet" href="{url:#css/ucenter.css}" />
<div class="mt10 clearfix" style="position: relative;">
	{widget:name=sub_navs action=ucsidebar sidebar=$sidebar act=$actionId}
	<div class="content clearfix uc-content">
		<div class="box p10">
			<h1 class="title"><span>{lang:MANAGE_MONEY}：</span></h1>
			<div class="box p15 mt10 clearfix">{lang:ACCOUNT_BANLANCE}：<b class="red f18">{$currency_symbol}{$customer['balance']|'0.00'}</b> <span class="fr"><a href="javascript:;" id="recharge-btn" class="btn btn-mini">充值</a> <a href="javascript:;" id="withdraw-btn" class="btn btn-mini">提现</a></span></div>
			<div class="mt10 tab">
				<ul class="tab-head">
					<li>{lang:TRADING_RECORD}</li>
					<li>{lang:CASH_OUT_RECORD}</li>
				</ul>
				<div class="tab-body">
					<div>
						<table class="simple">
							<tr>
								<th width="140">{lang:TIME}</th> <th width="120">{lang:DEPOSIT} / {lang:TAKE_OUT}</th><th width="120">{lang:BANLANCE}</th> <th >{lang:NOTE}</th> 
							</tr>
							{query:name=balance_log where=user_id eq $user[id] order=id desc page=1 id=$obj}
							<tr {if:$key%2==1}class="even"{/if}>
								<td>{$item['time']}</td> <td>{$item['amount']}</td><td>{$currency_symbol}{$item['amount_log']}</td><td>{$item['note']}</td>
							</tr>
							{/query}
						</table>
						<div class="page-nav">{echo:$obj->pagebar()}</div>
					</div>
					<div>
						<table class="simple">
							<tr>
								<th width="140">{lang:time}</th> <th width="120">{lang:WITHDRAWAL_AMOUNT}</th><th width="120">{lang:NAME}</th> <th >{lang:ACCOUNT}</th> <th style="width:80px">{lang:STATUS}</th> 
							</tr>
							{query:name=withdraw where=user_id eq $user[id] page=1 id=$withdraw}
							<tr {if:$item['status']==2}class="noborder"{/if}>
								<td width="140">{$item['time']}</td> <td width="120">{$currency_symbol}{$item['amount']}</td><td width="120">{$item['type_name']}</td> <td >{$item['account']}</td> <td style="width:80px">{if:$item['status']==0}<span class="red">{lang:BEING_PROCESSED}</span>{elseif:$item['status']==1}<b class="green">{lang:WITHDRAWAL_SUCCEED}</b>{else:}<span class="gray">{lang:FAIL}</span>{/if}</td>
							</tr>
							{if:$item['status']==2}
							<tr>
								<td colspan="5" style="padding-left:20px;"><p>{lang:HANDING_SUGGESTION}：{$item['re_note']} </p></td>
							</tr>
							{/if}
							{/query}
						</table>
						<div class="page-nav">{echo:$withdraw->pagebar()}</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<div id="recharge-dialog" class="hidden">
<form action="{url:/payment/dopay}" method="post" target="_blank" callback="close_dialog">
	<table class="form" style="width:500px;">
		<tr>
			<td class="label">{lang:RECHARGE_AMOUNT}：</td>
			<td><input type="text" name="recharge"  pattern="float" alt="最小金额不小于0.01"> <label></label></td>
		</tr>
		<tr>
			<td class="label">{lang:PAYMENT_METHOD}：</td>
			<td><select name="payment_id">
				{query:name=payment as py fields=py.* join= left join pay_plugin as pp on py.plugin_id eq pp.id where=pp.class_name ne 'balance' and pp.class_name ne 'received' order=sort desc}
				<option value="{$item['id']}">{$item['pay_name']}</option>
				{/query}
			</select></td>
		</tr>
		<tr>
			<td colspan="2" class="tc"><input type="submit" class="btn" value="{lang:RECHARGE_NOW}"></td>
		</tr>
	</table>
	</form>
</div>
<div  id="withdraw-dialog" class="hidden">
<form id="withdraw_form" action="{url:/ucenter/withdraw}" method="post" target="_blank" callback="submit_withdraw">
	<table class="form" style="width:600px;">
		<tr>
			<td class="label">{lang:ACCOUNT_BANLANCE}：</td>
			<td> <label class="f18 red">{$currency_symbol}{$customer['balance']}</label></td>
		</tr>
		<tr>
			<td class="label">{lang:WITHDRAWAL_AMOUNT}：</td>
			<td><input type="text" id="w_amount" name="amount" class="small"  pattern="float" min="1" max="{$customer['balance']}" alt="{lang:CAN_WITHDRAWAL_AMOUNT}(1 - {$customer['balance']})"> <label></label></td>
		</tr>
		<tr>
			<td class="label">{lang:ACCOUNT_NAME}：</td>
			<td><input type="text" id="w_name" name="name"  pattern="required" alt="{lang:OPENING_ACCOUNT_NAME}"> <label></label></td>
		</tr>
		<tr>
			<td class="label">{lang:BANK_OF_DEPOSIT}：</td>
			<td><input type="text" id="w_type_name" name="type_name"  pattern="required" alt="{lang:BANK_LIST_NAME}"> <label></label></td>
		</tr>
		<tr>
			<td class="label">{lang:ACCOUNT_NUMBER}：</td>
			<td><input type="text" id="w_account" name="account"  pattern="required" alt="{lang:BANK_LIST_NUMBER}"> <label></label></td>
		</tr>
		<tr>
			<td colspan="2" class="tc"><input type="submit" class="btn" value="{lang:WITHDRAWAL_APPLY}"></td>
		</tr>
	</table>
	</form>
</div>
<script type="text/javascript">
$("#recharge-btn").on("click",function() {
	art.dialog({id:'recharge-dialog',title:'{lang:RECHARGE_ONLINE}',content:document.getElementById('recharge-dialog'),lock:true});
});
$("#withdraw-btn").on("click",function() {
	art.dialog({id:'withdraw-dialog',title:'{lang:WITHDRAWAL_APPLY}',content:document.getElementById('withdraw-dialog'),lock:true});
});
function close_dialog(e){
	if(!e)art.dialog({id:'recharge-dialog'}).close();
}
function submit_withdraw(e){
	if(!e){
		var name = $("#w_name").val();
		var type_name = $("#w_type_name").val();
		var account = $("#w_account").val();
		var amount = $("#w_amount").val();
		$.get("{url:/ucenter/withdraw}",{name:name,type_name:type_name,account:account,amount:amount},function(data){
			if(data['status']=='success'){
				art.dialog({id:'withdraw-dialog'}).close();
				window.location.href = "{url:/ucenter/account/rand/}"+Math.random()+"#tab-1";
			}else{
				alert(data['msg']);
			}
		},'json');
	}
	return false;
}
</script>